package com.breeze.hllzdjd;

import android.accessibilityservice.AccessibilityService;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;

import java.util.List;

public class JDAccessibilityService extends AccessibilityService {
    private static final String TAG = "JDAccessibilityService";

    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
        Log.i(TAG, "onAccessibilityEvent: " + event);
        AccessibilityNodeInfo rootInActiveWindow = getRootInActiveWindow();
        List<AccessibilityNodeInfo> nodeInfos = rootInActiveWindow.findAccessibilityNodeInfosByText("测试订单");
        if (nodeInfos == null || nodeInfos.size() == 0) {
            return;
        }
        Log.i(TAG, "onAccessibilityEvent: " + nodeInfos.size());
        AccessibilityNodeInfo accessibilityNodeInfo = nodeInfos.get(0);
        AccessibilityHelper.performClick(accessibilityNodeInfo);
    }

    @Override
    public void onInterrupt() {
        Log.i(TAG, "onInterrupt: ");
    }
}
